<?php

namespace app\admin\validate;
use think\Validate;
use think\Db;

class Login extends Validate
{
	
	//验证规则
	protected $rule = [
		'username' => 'require|min:6|max:18',
		'password' => 'require|password',
		'ypassword' => 'require|password',
		'newpassword' => 'require|password',
		'renewpassword' => 'require|password',
	];
		
	
	//提示信息
	protected $message = [
		'username.require' => '用户名必须填写',
		'username.min' => '用户名最少不低于6个字符',
		'username.max' => '用户名最多不超过18个字符',
		
		'password.require' => '密码必须填写',
		'password.password' => '密码格式6-18个字母数字符号组合',
		
		'ypassword.require' => '原密码必须填写',
		'ypassword.password' => '密码格式6-18个字母数字符号组合',
		
		'newpassword.require' => '新密码必须填写',
		'newpassword.password' => '密码格式6-18个字母数字符号组合',
		
		'renewpassword.require' => '确认密码必须填写',
		'renewpassword.password' => '密码格式6-18个字母数字符号组合',
	
	];
	
	
	//自定义正则验证规则
	protected $regex = [
        'mobile'    => '/^(((1[0-9][0-9]{1})|159|153)+\d{8})$/',
        'password'  => '/(?!^[0-9]+$)(?!^[A-z]+$)(?!^[^A-z0-9]+$)^.{6,18}$/',
    ];
	
	
	//验证场景
	protected $scene = [
		//登录
        'login' => ['username','password'],
        //修改
        'resetpw' => ['ypassword','newpassword','renewpassword'],
	];
		
}
